set seed 21112023

***THIS CODE WILL GENERATE BOOTSTRAP SAMPLES, WHICH WE SAVE, THEN ESTIMATE IN A LATER DO FILE
**ALLOWS US TO RUN ESTIMATION ON MULTIPLE COMPUTERS (WHILE FIXING SEED)
local bsamplesize = 100


**************Decomposition Sample
use  "$working/ProdR_new_kl_3lags_sampleFS", clear
merge 1:1 co_code1 year using "$working/ProdR_new_kl_sampleSS"

generate samples = 1 if _merge==3
replace samples = 2 if _merge==1
replace samples = 3 if _merge==2
drop _merge

merge 1:m co_code1 year using "$working/ProdR_new_kl_3lags_sampleFS_prod"
drop _merge

save "$working/sample_new_kl_3lags", replace

forvalues bs = 1(1)`bsamplesize' {
	clear
	***Grab bootstrap samples
	use "$working/sample_new_kl_3lags"
	bsample,  strata(samples) cluster(co_code1) idcluster(bs_co_code1)
	save "$BS_fold_old/record/Rkl/3lags/bssample_`bs'", replace
}
